package com.ygxsk.carhome.ui.adapter;

import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.response.AttestationResultVo;
import com.ygxsk.carhome.utils.CommUtils;
import com.ygxsk.carhome.utils.TimeUtilSer;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import cn.bingoogolapple.photopicker.widget.BGANinePhotoLayout;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023-07-18  16:03
 * @Description: 车辆认证的适配器内容
 */
public class AuthManageDetailAdapter extends BaseQuickAdapter<AttestationResultVo, BaseViewHolder> {

    //填充一个代理进去,因为涉及到权限申请 放在activity之中用；
    private BGANinePhotoLayout.Delegate bgaNinePhotoLayoutDelegate;

    public void setBgaNinePhotoLayoutDelegate(BGANinePhotoLayout.Delegate _bgaNinePhotoLayoutDelegate) {
        bgaNinePhotoLayoutDelegate = _bgaNinePhotoLayoutDelegate;
    }

    public AuthManageDetailAdapter(int layoutResId, @Nullable List<AttestationResultVo> data) {
        super(layoutResId, data);

    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, AttestationResultVo attestationResultVo) {

        if (attestationResultVo != null) {

            //设置item数据；
            //认证体系？
            String authSystemCompany = attestationResultVo.getAttestationName();

            //认证时间
            Date authSystemTime = attestationResultVo.getCreateTime();
            String authSystemTimeResult = TimeUtils.date2String(authSystemTime, TimeUtilSer.simplemore);

            //认证车辆-当前的这个车辆；是三个信息拼接
//            String carBrandName = attestationResultVo.get;
//            String authSystemCarCurrent = attestationResultVo.get();
            //该条目的分配状态，其实应该是 审核状态：
            //String itemVerifyState = attestationResultVo.getSatateItem();
            //车辆的认证附件
            ArrayList<String> imgs = (ArrayList<String>) attestationResultVo.getImgs();


            //findViews
            //勾选按钮：
            //认证体系的名称
            TextView textViewAuthsSystem = (TextView) baseViewHolder.getView(R.id.textviewauthsystem);

            //认证时间
            TextView textViewAuthTime = (TextView) baseViewHolder.getView(R.id.textviewauthtime);

            //当前这个认证车辆--废弃不展示
            TextView textViewAuthCarCurrent = (TextView) baseViewHolder.getView(R.id.textviewauthcarcurrent);

            //认证附件的九宫格,图片信息 cn.bingoogolapple.photopicker.widget.BGANinePhotoLayout
            BGANinePhotoLayout npl_item_moment_photos_auth_detail = (BGANinePhotoLayout) baseViewHolder.getView(R.id.npl_item_moment_photos_auth_detail);


            //客户的预约时间
//            TextView textViewBookingTime = (TextView) baseViewHolder.getView(R.id.textviewbookingtimehistory);

            //车辆的 维修还是保养的区分标签
//            RoundTextView textViewRepairTypeTag = (RoundTextView) baseViewHolder.getView(R.id.textviewrepairtypetaghistory);

            //已进站的 按钮内容？
//            RoundTextView textViewRepairIntoStation = (RoundTextView) baseViewHolder.getView(R.id.textviewrepairintostation);
            //按钮的 改预约  按钮
//            RoundTextView textViewBookingChange = (RoundTextView) baseViewHolder.getView(R.id.textviewbookingchange);
            //取消预约按钮
//            RoundTextView textViewBookingCancel = (RoundTextView) baseViewHolder.getView(R.id.textviewbookingcancel);

            //认证体系
            CommUtils.setText(textViewAuthsSystem, authSystemCompany);
            //认证时间
            CommUtils.setText(textViewAuthTime, authSystemTimeResult);
            //认证车辆-顶部信息已经有了，底部去掉
            //CommUtils.setText(textViewAuthCarCurrent, authSystemCarCurrent);


            //联系人电话
//            CommUtils.setText(textViewContant, personPhone);
            //预约时间
//            CommUtils.setText(textViewBookingTime, timeChoose);
            //该预约单子的状态-分配状态
//            CommUtils.setText(textViewRepairAssignedState, itemState);

            //九宫格图片的查看信息：
            npl_item_moment_photos_auth_detail.setData(imgs);

            if (bgaNinePhotoLayoutDelegate != null) {
                npl_item_moment_photos_auth_detail.setDelegate(bgaNinePhotoLayoutDelegate);
            }
        }
    }

}
